﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WuDada.Core.Post;
using WuDada.Core.Post.Service;
using WuDada.Core.Post.Domain;

public partial class index : System.Web.UI.Page
{
    private PostFactory m_PostFactory;
    private IPostService m_PostService;

    //課程消息 m_NodeId = 4
    private int m_NodeId = 4;

    protected void Page_Load(object sender, EventArgs e)
    {
        m_PostFactory = new PostFactory();
        m_PostService = m_PostFactory.GetPostService();

        fillNews();
    }

    private void fillNews()
    {
        //搜尋條件
        Dictionary<string, string> conditions = new Dictionary<string, string>();
        conditions.Add("NodeId", m_NodeId.ToString());
        conditions.Add("Flag", "1");
        conditions.Add("PageIndex", "0");
        conditions.Add("PageSize", "3");

        Repeater1.DataSource = m_PostService.GetPostList(conditions);
        Repeater1.DataBind();
    }

    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        //if (e.Item.ItemIndex != -1)
        //{
        //    Control ctrl = e.Item;
        //    PostVO postVO = (PostVO)e.Item.DataItem;

        //    //內容
        //    int titleLength = 40; 
        //    if (!string.IsNullOrEmpty(postVO.Title))
        //    {
        //        string title = postVO.Title;
        //        if (title.Length > titleLength)
        //        {
        //            title = title.Substring(0, titleLength) + "...";
        //        }

        //        UIHelper.SetLiteralText(ctrl, "lblTitle", title);
        //    }
        //}
    }
}